

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>注册</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/layui-v2.5.5/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/login_web/admin.css" media="all">
  <link rel="stylesheet" href="/static/login_web/login.css" media="all">
  <link rel="icon" href="/static/img/default.ico">
</head>
<body>


  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>重置密码</h2>
        <p></p>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form" id="forget_form" lay-filter="forget_form">
        <div class="layui-form-item">
              <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-cellphone"></label>
              <input type="text" name="phone" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="请输入注册时的手机号" class="layui-input">
            </div>
            <div class="layui-form-item">
              <div class="layui-row">
                <div class="layui-col-xs7">
                  <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                  <input type="text" name="yz_code" id="LAY-user-login-vercode" lay-verify="required" placeholder="验证码" class="layui-input">
                </div>
                <div class="layui-col-xs5">
                  <div style="margin-left: 10px;" >
                    <a id="yz_code" class="layui-btn" style="background-color: rgba(255,255,255,.04);border: 0;color: black;position: absolute;right: 0px;width: 105px;font-size: 25px"></i></a>
                  </div>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-row">
                <div class="layui-col-xs7">
                  <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-smscode"></label>
                  <input type="text" name="v_code" id="LAY-user-login-smscode" lay-verify="required" placeholder="短信验证码" class="layui-input">
                </div>
                <div class="layui-col-xs5">
                  <div style="margin-left: 10px;">
                    <button id="cold_time" type="button" class="layui-btn layui-btn-primary layui-btn-fluid" onclick="get_v_code()">获取验证码</button>
                  </div>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
              <input type="password" name="password" id="LAY-user-login-password" lay-verify="pass" placeholder="新密码" class="layui-input">
            </div>
            <div class="layui-form-item">
              <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-repass"></label>
              <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="required" placeholder="确认密码" class="layui-input">
            </div>
            <div class="layui-form-item">
              <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="forget_form">重置密码</button>
            </div>
        </div>
        <div class="layui-trans layui-form-item layadmin-user-login-other">
          <!-- <label>社交账号注册</label>
          <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
          <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
          <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a> -->
          
          <a href="/" class="layadmin-user-jump-change layadmin-link layui-hide-xs">用已有帐号登入</a>
         <!--  <a href="login.html" class="layadmin-user-jump-change layadmin-link layui-hide-sm layui-show-xs-inline-block">登入</a> -->
        </div>
      </div>
    </div>
    
    <!-- <div class="layui-trans layadmin-user-login-footer">
      
      <p>© 2018 <a href="http://www.layui.com/" target="_blank">layui.com</a></p>
      <p>
        <span><a href="http://www.layui.com/admin/#get" target="_blank">获取授权</a></span>
        <span><a href="http://www.layui.com/admin/pro/" target="_blank">在线演示</a></span>
        <span><a href="http://www.layui.com/admin/" target="_blank">前往官网</a></span>
      </p>
    </div> -->

  </div>

  <script type="text/javascript" src="/static/layui-v2.5.5/layui.all.js"></script>
  <script>

    var $ = layui.$
    ,admin = layui.admin
    ,form = layui.form
    form.render();

    var yz_code=Math.ceil(Math.random()*10000)
    $('#yz_code').text(yz_code)

    //提交
    var get_v_code=function(){

    var param_data=form.val('forget_form')
    console.log(param_data)
    if(param_data.phone==''){
      layer.msg('请输入手机号码')
      return false
    }else if(param_data.phone.length!==11){
      layer.msg('请输入正确格式的手机号码')
      return false
    }
    if(param_data.yz_code!==yz_code.toString()){
      layer.msg('验证码错误')
      return false
    }
    console.log(param_data)
      ajax_url='?key=validation'
      $.ajax({
        type: 'POST',
        data:param_data,
        url:ajax_url,
        async:true,
        dataType: 'json',
        success: function(data) {
          // console.log(JSON.stringify(data))
          if(data.code==1000){
            layer.msg(data.data)
            var secs=60
            $('#cold_time').attr('class','layui-btn layui-btn-primary layui-btn-fluid layui-btn-disabled')
            var cold_time=setInterval(function(){
              $('#cold_time').text('获取（'+secs+'）')
              if(secs==0){
                clearInterval(cold_time);
                $('#cold_time').text('获取验证码')
                $('#cold_time').attr('class','layui-btn layui-btn-primary layui-btn-fluid')
                return
              }
              secs=secs-1
            },1000)
          }else{
            layer.msg(data.error)
          }
        },
      });
    }

    form.on('submit(forget_form)',function(obj){
      // console.log(obj.field)
      // layer.closeAll()
      var param_data=obj.field
      if(param_data.password!==param_data.repass){
        layer.msg('两次输入密码不一致！')
        return false
      }
      var ajax_url='?key=reset_pwd'
      $.ajax({
        type: 'POST',
        data:param_data,
        url:ajax_url,
        async:true,
        dataType: 'json',
        success: function(data) {
          // console.log(JSON.stringify(data))
          if(data.code==1000){
            layer.msg(data.data)
            setTimeout(function(){
              window.location.href = '/';
            },1000)
          }else{
            layer.msg(data.error)
          }
        },
      });
      return false
    })

  </script>
</body>
</html>